// import 'package:euromillions/tools/EJ_config.dart';
import 'package:flutter/material.dart';

import 'KaL_Config.dart';

class EJBallsView extends StatefulWidget {
  EJBallsView({super.key, required this.numbers});
  List numbers;
  @override
  State<EJBallsView> createState() => _EJBallsViewState();
}

class _EJBallsViewState extends State<EJBallsView> {
  ///
  double ballWH = 40;
  late var _numbers = [];
  List<Widget> _balls = [];

  @override
  Widget build(BuildContext context) {
    _balls.clear();
    _numbers = widget.numbers;
    for (var i = 0; i < _numbers.length; i++) {
      var element = _numbers[i];
      if (i < _numbers.length - 1) {
        _balls.add(regularBall(element));
      } else {
        _balls.add(extramBall(element));
      }
    }

    return Container(
      padding: const EdgeInsets.all(3),
      // color: Colors.yellow,
      child: Row(
        mainAxisSize: MainAxisSize.min, // Row 根据内容自适应宽度
        mainAxisAlignment: MainAxisAlignment.center,
        children: _balls,
      ),
    );
  }

  Widget regularBall(String number) {
    return Container(
      // color: Colors.white,
      width: ballWH,
      height: ballWH,
      padding: const EdgeInsets.all(2),
      child: Container(
        child: Center(
          child: Text(
            number,
            style: const TextStyle(
              fontWeight: FontWeight.w600,
              fontSize: 14,
              color: Colors.white,
            ),
          ),
        ),
        decoration: BoxDecoration(
            color: KaL_Config.KaL_themeColor_HL,
            borderRadius: BorderRadius.all(Radius.circular(ballWH * 0.5))),
      ),
    );
  }

  Widget extramBall(String number) {
    return Container(
      // color: Colors.white,
      width: ballWH + 2,
      height: ballWH + 2,
      padding: const EdgeInsets.all(2),
      child: Container(
        alignment: Alignment.center,
        padding: const EdgeInsets.only(top: 3),
        child: Text(
          number,
          style: const TextStyle(
            fontWeight: FontWeight.w600,
            fontSize: 14,
            color: Colors.black,
          ),
        ),
        // decoration: BoxDecoration(
        //   image: DecorationImage(
        //     image: AssetImage(
        //         'assets/systems_Imgs/extramNum_Star.png'), // 替换为您的图片路径
        //     fit: BoxFit.cover, // 图片填充方式
        //   ),
        // ),
      ),
    );
  }
}
